﻿Imports System.IO
Imports System.Xml
Module LoadMobile
    Public Sub LoadMob(ByVal MobVIRID As String, Optional ByVal LoadScripts As Boolean = True)
        'declare xml dimensions
        Dim m_xmld, m_xmld2 As XmlDocument
        Dim m_nodelist, m_nodelist2 As XmlNodeList
        Dim m_node, m_node2 As XmlNode
        Dim CurNumber As String
        Dim Found As Boolean
        Try
            m_xmld = New XmlDocument() : m_xmld2 = New XmlDocument()
            m_xmld.Load(Replace(MainProgram.DirMobs, "Mobs.TG", "Mobs.xml"))
            m_nodelist = m_xmld.SelectNodes("/mobilelist/mob")
            For Each m_node In m_nodelist
                CurNumber = m_node.Attributes.GetNamedItem("number").Value
                If Val(CurNumber) = Val(MobVIRID) Then 'found the mobile!
                    MainProgram.MobData_SHORT = m_node.ChildNodes.Item(0).InnerText
                    MainProgram.MobData_MNAME = m_node.ChildNodes.Item(1).InnerText
                    'now load the archetypes xml document and parse to locate the archetype
                    m_xmld2.Load(Replace(MainProgram.DirMobs, "Mobs.TG", "Archetypes.xml"))
                    m_nodelist2 = m_xmld2.SelectNodes("/archetypelist/archetype")
                    For Each m_node2 In m_nodelist2
                        CurNumber = m_node2.Attributes.GetNamedItem("number").Value
                        If Val(CurNumber) = Val(m_node.ChildNodes.Item(2).ChildNodes.Item(0).InnerText) Then 'found the province
                            Dim bob As String
                            bob = m_node2.ChildNodes.Item(0).InnerText
                            MainProgram.MobData_ARCHE = m_node2.ChildNodes.Item(0).InnerText
                            Found = True
                            Exit For
                        End If
                    Next
                    If Found = False Then MainProgram.MobData_ARCHE = "Unknown"
                    'now load the race type xml document and parse to locate the race tye
                    m_xmld2.Load(Replace(MainProgram.DirMobs, "Mobs.TG", "Races.xml"))
                    m_nodelist2 = m_xmld2.SelectNodes("/racelist/race")
                    For Each m_node2 In m_nodelist2
                        CurNumber = m_node2.Attributes.GetNamedItem("number").Value
                        If Val(CurNumber) = 0 Then
                            MainProgram.MobData_Sentient = "Yes"
                            Found = True
                            Exit For
                        ElseIf Val(CurNumber) = Val(m_node.ChildNodes.Item(2).ChildNodes.Item(1).InnerText) Then 'found the province
                            MainProgram.MobData_RACET = m_node2.ChildNodes.Item(0).InnerText
                            Found = True
                            Exit For
                        End If
                    Next
                    If Found = False Then MainProgram.MobData_RACET = "Unkown"
                    MainProgram.MobData_HATE_race = m_node.ChildNodes.Item(2).ChildNodes.Item(2).InnerText
                    MainProgram.MobData_HATE_class = m_node.ChildNodes.Item(2).ChildNodes.Item(3).InnerText
                    MainProgram.MobData_HATE_sex = m_node.ChildNodes.Item(2).ChildNodes.Item(3).InnerText
                    'Temperament, exa: Coward, aggressive
                    MainProgram.MobData_TEMPE = m_node.ChildNodes.Item(2).ChildNodes.Item(4).InnerText
                    'Rank Type exa: Regular, Boss, Miniboss
                    MainProgram.MobData_MobType = m_node.ChildNodes.Item(2).ChildNodes.Item(5).InnerText
                    MainProgram.MobData_MobClass = m_node.ChildNodes.Item(2).ChildNodes.Item(6).InnerText
                    MainProgram.MobData_MobClassCombatPreset = m_node.ChildNodes.Item(2).ChildNodes.Item(7).InnerText
                    MainProgram.MobData_PATHTYPE = m_node.ChildNodes.Item(3).Attributes.GetNamedItem("is").Value
                    If MainProgram.MobData_PATHTYPE > 0 Then
                        MainProgram.MobData_PATH = m_node.ChildNodes.Item(3).InnerText
                    Else
                        MainProgram.MobData_PATH = ""
                    End If
                    If Val(m_node.ChildNodes.Item(4).Attributes.GetNamedItem("is").Value) > 0 Then
                        MainProgram.MobData_Mer = True
                        If Val(m_node.ChildNodes.Item(4).ChildNodes.Item(0).InnerText) > 0 Then
                            MainProgram.MobData_Mer_SellsInventory = True : Else
                            MainProgram.MobData_Mer_SellsInventory = False : End If
                        If Val(m_node.ChildNodes.Item(4).ChildNodes.Item(1).InnerText) > 0 Then
                            MainProgram.MobData_Mer_FavorsClass = True : Else
                            MainProgram.MobData_Mer_FavorsClass = False : End If
                        If Val(m_node.ChildNodes.Item(4).ChildNodes.Item(2).InnerText) > 0 Then
                            MainProgram.MobData_Mer_FavorsGender = True : Else
                            MainProgram.MobData_Mer_FavorsGender = False : End If
                        If Val(m_node.ChildNodes.Item(4).ChildNodes.Item(3).InnerText) > 0 Then
                            MainProgram.MobData_Mer_FavorsRace = True : Else
                            MainProgram.MobData_Mer_FavorsRace = False : End If
                        Dim CurPosition, LastPosition As Integer, WealthString As String = m_node.ChildNodes.Item(4).ChildNodes.Item(3).InnerText
                        For CurPosition = 1 To Len(WealthString) Step 1
                            If Mid(WealthString, CurPosition, 1) = "S" Then
                                MainProgram.MobData_Mer_WealthSovern = Val(Mid(WealthString, 1, CurPosition - 1))
                                LastPosition = CurPosition + 1
                            ElseIf Mid(WealthString, CurPosition, 1) = "D" Then
                                MainProgram.MobData_Mer_WealthDover = Val(Mid(WealthString, LastPosition, CurPosition - LastPosition))
                                LastPosition = CurPosition + 1
                            ElseIf Mid(WealthString, CurPosition, 1) = "V" Then
                                MainProgram.MobData_Mer_WealthVern = Val(Mid(WealthString, LastPosition, CurPosition - LastPosition))
                                Exit For
                            End If
                        Next
                        If Val(m_node.ChildNodes.Item(4).ChildNodes.Item(5).InnerText) > 0 Then
                            MainProgram.MobData_Mer_BuysWeapons = True : Else
                            MainProgram.MobData_Mer_BuysWeapons = False : End If
                        If Val(m_node.ChildNodes.Item(4).ChildNodes.Item(6).InnerText) > 0 Then
                            MainProgram.MobData_Mer_SellsWeapons = True : Else
                            MainProgram.MobData_Mer_SellsWeapons = False : End If
                        MainProgram.MobData_Mer_WeaponValue = Val(m_node.ChildNodes.Item(4).ChildNodes.Item(7).InnerText)
                        If Val(m_node.ChildNodes.Item(4).ChildNodes.Item(8).InnerText) > 0 Then
                            MainProgram.MobData_Mer_BuysArmor = True : Else
                            MainProgram.MobData_Mer_BuysArmor = False : End If
                        If Val(m_node.ChildNodes.Item(4).ChildNodes.Item(9).InnerText) > 0 Then
                            MainProgram.MobData_Mer_SellsArmor = True : Else
                            MainProgram.MobData_Mer_SellsArmor = False : End If
                        MainProgram.MobData_Mer_ArmorValue = Val(m_node.ChildNodes.Item(4).ChildNodes.Item(10).InnerText)
                        If Val(m_node.ChildNodes.Item(4).ChildNodes.Item(11).InnerText) > 0 Then
                            MainProgram.MobData_Mer_BuysMisc = True : Else
                            MainProgram.MobData_Mer_BuysMisc = False : End If
                        If Val(m_node.ChildNodes.Item(4).ChildNodes.Item(12).InnerText) > 0 Then
                            MainProgram.MobData_Mer_SellsMisc = True : Else
                            MainProgram.MobData_Mer_SellsMisc = False : End If
                        MainProgram.MobData_Mer_MiscValue = Val(m_node.ChildNodes.Item(4).ChildNodes.Item(13).InnerText)
                    Else
                        MainProgram.MobData_Mer = False
                    End If
                    Dim ItemDropNumber As Short = Val(m_node.ChildNodes.Item(5).Attributes.GetNamedItem("is").Value)
                    If ItemDropNumber > 0 Then MainProgram.MobData_DROP_static1 = m_node.ChildNodes.Item(5).ChildNodes.Item(0).InnerText Else MainProgram.MobData_DROP_static1 = ""
                    If ItemDropNumber > 1 Then MainProgram.MobData_DROP_static2 = m_node.ChildNodes.Item(5).ChildNodes.Item(1).InnerText Else MainProgram.MobData_DROP_static2 = ""
                    If ItemDropNumber > 2 Then MainProgram.MobData_DROP_static3 = m_node.ChildNodes.Item(5).ChildNodes.Item(2).InnerText Else MainProgram.MobData_DROP_static3 = ""
                    If ItemDropNumber > 3 Then MainProgram.MobData_DROP_static4 = m_node.ChildNodes.Item(5).ChildNodes.Item(3).InnerText Else MainProgram.MobData_DROP_static4 = ""
                    If ItemDropNumber > 4 Then MainProgram.MobData_DROP_static5 = m_node.ChildNodes.Item(5).ChildNodes.Item(4).InnerText Else MainProgram.MobData_DROP_static5 = ""
                    If ItemDropNumber > 5 Then MainProgram.MobData_DROP_dynamic1 = m_node.ChildNodes.Item(5).ChildNodes.Item(5).InnerText Else MainProgram.MobData_DROP_dynamic1 = ""
                    If ItemDropNumber > 6 Then MainProgram.MobData_DROP_dynamic2 = m_node.ChildNodes.Item(5).ChildNodes.Item(6).InnerText Else MainProgram.MobData_DROP_dynamic2 = ""
                    If ItemDropNumber > 7 Then MainProgram.MobData_DROP_dynamic3 = m_node.ChildNodes.Item(5).ChildNodes.Item(7).InnerText Else MainProgram.MobData_DROP_dynamic3 = ""
                    If ItemDropNumber > 8 Then MainProgram.MobData_DROP_dynamic4 = m_node.ChildNodes.Item(5).ChildNodes.Item(8).InnerText Else MainProgram.MobData_DROP_dynamic4 = ""
                    If ItemDropNumber > 9 Then MainProgram.MobData_DROP_dynamic5 = m_node.ChildNodes.Item(5).ChildNodes.Item(9).InnerText Else MainProgram.MobData_DROP_dynamic5 = ""
                    MainProgram.MobData_LDESC = m_node.ChildNodes.Item(6).InnerText
                    'changed from TG version to suppliment merely quest ID# not the intro, now identifying quests will be more difficult
                    MainProgram.MobData_SCRIT = m_node.ChildNodes.Item(7).InnerText
                    Dim CurrentDamageString = Val(m_node.ChildNodes.Item(8).Attributes.GetNamedItem("number").Value)
                    If CurrentDamageString > 0 Then
                        For CurrentDamageString = CurrentDamageString To 1 Step -1
                            MainProgram.MobData_DamageName(CurrentDamageString) = m_node.ChildNodes.Item(8).ChildNodes.Item(CurrentDamageString).ChildNodes.Item(0).InnerText
                            MainProgram.MobData_DamageDieNum(CurrentDamageString) = m_node.ChildNodes.Item(8).ChildNodes.Item(CurrentDamageString).ChildNodes.Item(1).InnerText
                            MainProgram.MobData_DamageDieType(CurrentDamageString) = m_node.ChildNodes.Item(8).ChildNodes.Item(CurrentDamageString).ChildNodes.Item(2).InnerText
                            MainProgram.MobData_DamageType(CurrentDamageString) = m_node.ChildNodes.Item(8).ChildNodes.Item(CurrentDamageString).ChildNodes.Item(3).InnerText
                            MainProgram.MobData_DamageSpeed(CurrentDamageString) = m_node.ChildNodes.Item(8).ChildNodes.Item(CurrentDamageString).ChildNodes.Item(4).InnerText
                            MainProgram.MobData_DamageCrit(CurrentDamageString) = m_node.ChildNodes.Item(8).ChildNodes.Item(CurrentDamageString).ChildNodes.Item(5).InnerText
                        Next
                    End If
                    MainProgram.MobData_HITPO = m_node.ChildNodes.Item(9).InnerText
                    MainProgram.MobData_WILLP = m_node.ChildNodes.Item(10).InnerText
                    MainProgram.MobData_STAMP = m_node.ChildNodes.Item(11).InnerText
                    MainProgram.MobData_LEVEL = m_node.ChildNodes.Item(12).InnerText
                    'weight is not yet supported
                    'MainProgram.mobdata_weight = m_node.ChildNodes.Item(13).InnerText
                Exit For
                End If
            Next
        Catch errorVariable As Exception
            MainProgram.SND("/RERROR: " + errorVariable.ToString())
        End Try
        Dim npcnum As String = MobVIRID
        MainProgram.MobData_VIRID = MobVIRID
        Dim mscstr As String = ""
        Dim stepnum As Integer = 0
        Dim tmp0 As Integer
        Dim tmp1 As Integer
        Dim tmp2 As Integer
        Dim tmp3 As Integer
        '@@@@@@@@@@@@@@@@  A D D    L O V E
        MainProgram.MobData_LOVE_class = "None"
        MainProgram.MobData_LOVE_race = "None"
        MainProgram.MobData_LOVE_sex = "None"
        tmp0 = InStr(MainProgram.MobData, "PARID#" + npcnum + "(")
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "PARID#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "PARID#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "PARID#" + npcnum + "(") - 7 - Len(npcnum))
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                            ElseIf stepnum = 1 Then
                                If Len(Mid(mscstr, tmp3, tmp2 - tmp3)) = 2 Then
                                    
                                Else
                                    MainProgram.MobData_Sentient = "No"
                                    Try
                                        m_xmld = New XmlDocument()
                                        m_xmld.Load(Replace(MainProgram.DirMobs, "Mobs.TG", "TL.Creatures.xml"))
                                        m_nodelist = m_xmld.SelectNodes("/itemlist/item")
                                        For Each m_node In m_nodelist
                                            CurNumber = m_node.Attributes.GetNamedItem("number").Value
                                            If Val(CurNumber) = Val(Mid(mscstr, tmp3, tmp2 - tmp3)) Then 'found the province
                                                Dim bob As String
                                                bob = m_node.ChildNodes.Item(0).ChildNodes.Item(0).InnerText
                                                MainProgram.MobData_RACET = m_node.ChildNodes.Item(0).ChildNodes.Item(0).InnerText
                                                Found = True
                                                Exit For
                                            End If
                                        Next
                                    Catch errorVariable As Exception
                                        MainProgram.SND("/RERROR: " + errorVariable.ToString())
                                    End Try
                                    If Found = False Then MainProgram.MobData_RACET = "Unknown"
                                    tmp3 = tmp2 + 1
                                    stepnum += 1
                                End If
                            ElseIf stepnum = 2 Then
                                Try
                                    m_xmld = New XmlDocument()
                                    m_xmld.Load(Replace(MainProgram.DirMobs, "Mobs.TG", "Races.xml"))
                                    m_nodelist = m_xmld.SelectNodes("/racelist/race")
                                    For Each m_node In m_nodelist
                                        CurNumber = m_node.Attributes.GetNamedItem("number").Value
                                        If Val(CurNumber) = Val(Mid(mscstr, tmp3, tmp2 - tmp3)) Then 'found the province
                                            MainProgram.MobData_RACET = m_node.ChildNodes.Item(0).InnerText
                                            Found = True
                                            Exit For
                                        End If
                                    Next
                                Catch errorVariable As Exception
                                    MainProgram.SND("/RERROR: " + errorVariable.ToString())
                                End Try
                                If Found = False Then MainProgram.MobData_RACET = "Unknown"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 3 Then
                                Try
                                    m_xmld = New XmlDocument()
                                    m_xmld.Load(Replace(MainProgram.DirMobs, "Mobs.TG", "Classes.xml"))
                                    m_nodelist = m_xmld.SelectNodes("/classlist/class")
                                    For Each m_node In m_nodelist
                                        CurNumber = m_node.Attributes.GetNamedItem("number").Value
                                        If Val(CurNumber) = Val(Mid(mscstr, tmp3, tmp2 - tmp3)) Then 'found the province
                                            MainProgram.MobData_HATE_class = m_node.ChildNodes.Item(0).InnerText
                                            Found = True
                                            Exit For
                                        End If
                                    Next
                                Catch errorVariable As Exception
                                    MainProgram.SND("/RERROR: " + errorVariable.ToString())
                                End Try
                                If Found = False Then MainProgram.MobData_HATE_class = "Unknown"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 4 Then
                                If Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 0 Then
                                    MainProgram.MobData_HATE_sex = "None"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 1 Then
                                    MainProgram.MobData_HATE_sex = "Males"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 2 Then
                                    MainProgram.MobData_HATE_sex = "Females"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 3 Then
                                    MainProgram.MobData_HATE_sex = "Neutrals"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 4 Then
                                    MainProgram.MobData_HATE_sex = "Males and Females"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 5 Then
                                    MainProgram.MobData_HATE_sex = "Males and Neutrals"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 6 Then
                                    MainProgram.MobData_HATE_sex = "Females and Neutrals"
                                Else
                                    MainProgram.MobData_HATE_sex = "Unknown"
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 5 Then
                                If Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 0 Then
                                    MainProgram.MobData_TEMPE = "Passive"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 1 Then
                                    MainProgram.MobData_TEMPE = "Agressive"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 2 Then
                                    MainProgram.MobData_TEMPE = "Coward"
                                Else
                                    MainProgram.MobData_TEMPE = "Unknown"
                                End If
                                MainProgram.MobData_TEMPE = ""
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 6 Then
                                If Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 0 Then
                                    MainProgram.MobData_MobType = "Regular"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 1 Then
                                    MainProgram.MobData_MobType = "Mini-Boss"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 2 Then
                                    MainProgram.MobData_MobType = "Boss"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 3 Then
                                    MainProgram.MobData_MobType = "Rare"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 4 Then
                                    MainProgram.MobData_MobType = "Ultra Rare"
                                ElseIf Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 5 Then
                                    MainProgram.MobData_MobType = "Epic"
                                Else
                                    MainProgram.MobData_MobType = "Unknown"
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 7 Then
                                Try
                                    m_xmld = New XmlDocument()
                                    m_xmld.Load(Replace(MainProgram.DirMobs, "Mobs.TG", "Classes.xml"))
                                    m_nodelist = m_xmld.SelectNodes("/classlist/class")
                                    For Each m_node In m_nodelist
                                        CurNumber = m_node.Attributes.GetNamedItem("number").Value
                                        If Val(CurNumber) = Val(Mid(mscstr, tmp3, tmp2 - tmp3)) Then 'found the province
                                            MainProgram.MobData_MobClass = m_node.ChildNodes.Item(0).InnerText
                                            Found = True
                                            Exit For
                                        End If
                                    Next
                                Catch errorVariable As Exception
                                    MainProgram.SND("/RERROR: " + errorVariable.ToString())
                                End Try
                                If Found = False Then MainProgram.MobData_MobClass = "Unknown"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 8 Then
                                If Val(Mid(mscstr, tmp3, tmp2 - tmp3)) = 0 Then
                                    MainProgram.MobData_MobClassCombatPreset = "Unknown"
                                Else
                                    MainProgram.MobData_MobClassCombatPreset = "Unknown"
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                                Exit For
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        'redo
        tmp0 = InStr(MainProgram.MobData, "MOBMV#" + npcnum + "(")
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "MOBMV#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "MOBMV#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "MOBMV#" + npcnum + "(") - 7 - Len(npcnum))
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                If Mid(mscstr, 1, tmp2 - 1) = "0" Then
                                    MainProgram.MobData_PATHTYPE = 0
                                    MainProgram.MobData_PATH = ""
                                    stepnum = -1
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "1" Then
                                    MainProgram.MobData_PATHTYPE = 1
                                    stepnum += 1
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "2" Then
                                    MainProgram.MobData_PATHTYPE = 2
                                    stepnum += 1
                                ElseIf Mid(mscstr, 1, tmp2 - 1) = "3" Then
                                    MainProgram.MobData_PATHTYPE = 3
                                    stepnum += 1
                                End If
                                tmp3 = tmp2 + 1
                            ElseIf stepnum = 1 Then
                                MainProgram.MobData_PATH = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "MOBME#" + npcnum + "(")
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "MOBME#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "MOBME#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "MOBME#" + npcnum + "(") - 7 - Len(npcnum))
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                If Mid(mscstr, tmp3, tmp2 - 1) = "1" Then
                                    MainProgram.MobData_Mer = True
                                Else
                                    MainProgram.MobData_Mer = False
                                    Exit For
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 1 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_SellsInventory = True
                                Else
                                    MainProgram.MobData_Mer_SellsInventory = False
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 2 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_FavorsClass = True
                                Else
                                    MainProgram.MobData_Mer_FavorsClass = False
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 3 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_FavorsGender = True
                                Else
                                    MainProgram.MobData_Mer_FavorsGender = False
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 4 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_FavorsRace = True
                                Else
                                    MainProgram.MobData_Mer_FavorsRace = False
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 5 Then 'finish this
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_Wealth = True
                                Else
                                    MainProgram.MobData_Mer_Wealth = False
                                    Dim tmp10 As Integer, tmpA As String = Mid(mscstr, tmp3, tmp2 - tmp3), tmp11 As Integer = 0
                                    For tmp10 = 1 To Len(tmpA) Step 1
                                        If Mid(tmpA, tmp10, 1) = "S" Then
                                            MainProgram.MobData_Mer_WealthSovern = Val(Mid(tmpA, 1, tmp10 - 1))
                                            tmp11 = tmp10 + 1
                                        ElseIf Mid(tmpA, tmp10, 1) = "D" Then
                                            MainProgram.MobData_Mer_WealthDover = Val(Mid(tmpA, tmp11, tmp10 - tmp11))
                                            tmp11 = tmp10 + 1
                                        ElseIf Mid(tmpA, tmp10, 1) = "V" Then
                                            MainProgram.MobData_Mer_WealthVern = Val(Mid(tmpA, tmp11, tmp10 - tmp11))
                                            Exit For
                                        End If
                                    Next
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 6 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_BuysWeapons = True
                                Else
                                    MainProgram.MobData_Mer_BuysWeapons = False
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 7 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_SellsWeapons = True
                                Else
                                    MainProgram.MobData_Mer_SellsWeapons = False
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 8 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_WeaponValue = 1
                                ElseIf Mid(mscstr, tmp3, tmp2 - tmp3) = "2" Then
                                    MainProgram.MobData_Mer_WeaponValue = 2
                                Else
                                    MainProgram.MobData_Mer_WeaponValue = 0
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 9 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_BuysArmor = True
                                Else
                                    MainProgram.MobData_Mer_BuysArmor = False
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 10 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_SellsArmor = True
                                Else
                                    MainProgram.MobData_Mer_SellsArmor = False
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 11 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_ArmorValue = 1
                                ElseIf Mid(mscstr, tmp3, tmp2 - tmp3) = "2" Then
                                    MainProgram.MobData_Mer_ArmorValue = 2
                                Else
                                    MainProgram.MobData_Mer_ArmorValue = 0
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 12 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_BuysMisc = True
                                Else
                                    MainProgram.MobData_Mer_BuysMisc = False
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 13 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_SellsMisc = True
                                Else
                                    MainProgram.MobData_Mer_SellsMisc = False
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 14 Then
                                If Mid(mscstr, tmp3, tmp2 - tmp3) = "1" Then
                                    MainProgram.MobData_Mer_MiscValue = 1
                                ElseIf Mid(mscstr, tmp3, tmp2 - tmp3) = "2" Then
                                    MainProgram.MobData_Mer_MiscValue = 2
                                Else
                                    MainProgram.MobData_Mer_MiscValue = 0
                                End If
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "MOBTE#" + npcnum + "(")
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "MOBTE#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "MOBTE#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "MOBTE#" + npcnum + "(") - 7 - Len(npcnum))
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                MainProgram.MobData_DROP_static1 = Mid(mscstr, 1, tmp2 - 1)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 1 Then
                                MainProgram.MobData_DROP_static2 = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 2 Then
                                MainProgram.MobData_DROP_static3 = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 3 Then
                                MainProgram.MobData_DROP_static4 = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 4 Then
                                MainProgram.MobData_DROP_static5 = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 5 Then
                                MainProgram.MobData_DROP_dynamic1 = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 6 Then
                                MainProgram.MobData_DROP_dynamic2 = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 7 Then
                                MainProgram.MobData_DROP_dynamic3 = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 8 Then
                                MainProgram.MobData_DROP_dynamic4 = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 9 Then
                                MainProgram.MobData_DROP_dynamic5 = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum = 0
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "LOOKD#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(MainProgram.MobData, "LOOKD#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    MainProgram.MobData_LDESC = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "LOOKD#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "LOOKD#" + npcnum + "(") - 7 - Len(npcnum))
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "SCRIT#" + npcnum + "(")
        MainProgram.MobData_HasQuest = False
        If tmp0 > 0 Then
            For tmp1 = InStr(MainProgram.MobData, "SCRIT#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    MainProgram.MobData_SCRIT = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "SCRIT#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "SCRIT#" + npcnum + "(") - 7 - Len(npcnum))
                    For tmp2 = 1 To Len(MainProgram.MobData_SCRIT) Step 1
                        If Mid(MainProgram.MobData_SCRIT, tmp2, 1) = "." Then
                            If LoadScripts = True Then LoadScript.LoadScript(Mid(MainProgram.MobData_SCRIT, 1, tmp2 - 1))
                            Exit For
                        End If
                    Next
                    If InStr(MainProgram.ScriptData_OPTIONS, "<?Q") Then
                        MainProgram.MobData_HasQuest = True
                    End If
                    Exit For
                End If
            Next
        End If
        MainProgram.MobData_DamageSpeed(0) = ""
        MainProgram.MobData_DamageCrit(0) = ""
        MainProgram.MobData_DamageDieNum(0) = ""
        MainProgram.MobData_DamageDieType(0) = ""
        MainProgram.MobData_DamageName(0) = ""
        MainProgram.MobData_DamageType(0) = ""
        MainProgram.MobData_DamageSpeed(1) = ""
        MainProgram.MobData_DamageCrit(1) = ""
        MainProgram.MobData_DamageDieNum(1) = ""
        MainProgram.MobData_DamageDieType(1) = ""
        MainProgram.MobData_DamageName(1) = ""
        MainProgram.MobData_DamageType(1) = ""
        MainProgram.MobData_DamageSpeed(2) = ""
        MainProgram.MobData_DamageCrit(2) = ""
        MainProgram.MobData_DamageDieNum(2) = ""
        MainProgram.MobData_DamageDieType(2) = ""
        MainProgram.MobData_DamageName(2) = ""
        MainProgram.MobData_DamageType(2) = ""
        MainProgram.MobData_DamageSpeed(3) = ""
        MainProgram.MobData_DamageCrit(3) = ""
        MainProgram.MobData_DamageDieNum(3) = ""
        MainProgram.MobData_DamageDieType(3) = ""
        MainProgram.MobData_DamageName(3) = ""
        MainProgram.MobData_DamageType(3) = ""
        MainProgram.MobData_DamageSpeed(4) = ""
        MainProgram.MobData_DamageCrit(4) = ""
        MainProgram.MobData_DamageDieNum(4) = ""
        MainProgram.MobData_DamageDieType(4) = ""
        MainProgram.MobData_DamageName(4) = ""
        MainProgram.MobData_DamageType(4) = ""
        tmp0 = InStr(MainProgram.MobData, "DAMTY#" + npcnum + "(")
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "DAMTY#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "DAMTY#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "DAMTY#" + npcnum + "(") - 7 - Len(npcnum))
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 2 Then
                                Dim tmp4 As Short
                                Dim tmp5 As Short = 0
                                Dim tmp6 As Short
                                Dim tmpstr As String = Mid(mscstr, 1, tmp2 - 1)
                                For tmp4 = 1 To Len(tmpstr) Step 1
                                    If Mid(tmpstr, tmp4, 1) = "[" Then
                                        MainProgram.MobData_DamageName(0) = Mid(tmpstr, 1, tmp4 - 1)
                                        tmp6 = tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "d" Then
                                        MainProgram.MobData_DamageDieNum(0) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "]" Then
                                        MainProgram.MobData_DamageDieType(0) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "{" Then
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "," Then
                                        If tmp5 = 0 Then
                                            MainProgram.MobData_DamageType(0) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                            tmp6 = +tmp4 + 1
                                            tmp5 += 1
                                        Else
                                            MainProgram.MobData_DamageSpeed(0) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                            tmp6 = +tmp4 + 1
                                        End If
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "}" Then
                                        MainProgram.MobData_DamageCrit(0) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                        Exit For
                                    End If
                                Next
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 5 Then
                                Dim tmp4 As Short
                                Dim tmp5 As Short = 0
                                Dim tmp6 As Short = tmp3
                                Dim tmpstr As String = Mid(mscstr, 1, tmp2 - 1)
                                For tmp4 = tmp3 To Len(tmpstr) Step 1
                                    If Mid(tmpstr, tmp4, 1) = "[" Then
                                        MainProgram.MobData_DamageName(1) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "d" Then
                                        MainProgram.MobData_DamageDieNum(1) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "]" Then
                                        MainProgram.MobData_DamageDieType(1) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "{" Then
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "," Then
                                        If tmp5 = 0 Then
                                            MainProgram.MobData_DamageType(1) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                            tmp6 = +tmp4 + 1
                                            tmp5 += 1
                                        Else
                                            MainProgram.MobData_DamageSpeed(1) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                            tmp6 = +tmp4 + 1
                                        End If
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "}" Then
                                        MainProgram.MobData_DamageCrit(1) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                        Exit For
                                    End If
                                Next
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 8 Then
                                Dim tmp4 As Short
                                Dim tmp5 As Short = 0
                                Dim tmp6 As Short = tmp3
                                Dim tmpstr As String = Mid(mscstr, 1, tmp2 - 1)
                                For tmp4 = tmp3 To Len(tmpstr) Step 1
                                    If Mid(tmpstr, tmp4, 1) = "[" Then
                                        MainProgram.MobData_DamageName(2) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "d" Then
                                        MainProgram.MobData_DamageDieNum(2) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "]" Then
                                        MainProgram.MobData_DamageDieType(2) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "{" Then
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "," Then
                                        If tmp5 = 0 Then
                                            MainProgram.MobData_DamageType(2) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                            tmp6 = +tmp4 + 1
                                            tmp5 += 1
                                        Else
                                            MainProgram.MobData_DamageSpeed(2) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                            tmp6 = +tmp4 + 1
                                        End If
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "}" Then
                                        MainProgram.MobData_DamageCrit(2) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    End If
                                Next
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 11 Then
                                Dim tmp4 As Short
                                Dim tmp5 As Short = 0
                                Dim tmp6 As Short = tmp3
                                Dim tmpstr As String = Mid(mscstr, 1, tmp2 - 1)
                                For tmp4 = tmp3 To Len(tmpstr) Step 1
                                    If Mid(tmpstr, tmp4, 1) = "[" Then
                                        MainProgram.MobData_DamageName(3) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "d" Then
                                        MainProgram.MobData_DamageDieNum(3) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "]" Then
                                        MainProgram.MobData_DamageDieType(3) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "{" Then
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "," Then
                                        If tmp5 = 0 Then
                                            MainProgram.MobData_DamageType(3) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                            tmp6 = +tmp4 + 1
                                            tmp5 += 1
                                        Else
                                            MainProgram.MobData_DamageSpeed(3) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                            tmp6 = +tmp4 + 1
                                        End If
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "}" Then
                                        MainProgram.MobData_DamageCrit(3) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    End If
                                Next
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 14 Then
                                Dim tmp4 As Short
                                Dim tmp5 As Short = 0
                                Dim tmp6 As Short = tmp3
                                Dim tmpstr As String = Mid(mscstr, 1, tmp2 - 1)
                                For tmp4 = tmp3 To Len(tmpstr) Step 1
                                    If Mid(tmpstr, tmp4, 1) = "[" Then
                                        MainProgram.MobData_DamageName(4) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "d" Then
                                        MainProgram.MobData_DamageDieNum(4) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "]" Then
                                        MainProgram.MobData_DamageDieType(4) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "{" Then
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "," Then
                                        If tmp5 = 0 Then
                                            MainProgram.MobData_DamageType(4) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                            tmp6 = +tmp4 + 1
                                            tmp5 += 1
                                        Else
                                            MainProgram.MobData_DamageSpeed(4) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                            tmp6 = +tmp4 + 1
                                        End If
                                        tmp6 = +tmp4 + 1
                                    ElseIf Mid(tmpstr, tmp4, 1) = "}" Then
                                        MainProgram.MobData_DamageCrit(4) = Mid(tmpstr, tmp6, tmp4 - tmp6)
                                        tmp6 = +tmp4 + 1
                                    End If
                                Next
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            Else
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "ARMOR#" + npcnum + "(")
        MainProgram.MobData_AC_bash = "0"
        MainProgram.MobData_AC_slash = "0"
        MainProgram.MobData_AC_pierce = "0"
        MainProgram.MobData_AC_fist = "0"
        MainProgram.MobData_AC_exotic = "0"
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "ARMOR#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Mid(MainProgram.MobData, InStr(MainProgram.MobData, "ARMOR#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "ARMOR#" + npcnum + "(") - 7 - Len(npcnum)), "BashAC", ""), "SlashAC", ""), "PierceAC", ""), "FistAC", ""), "ExoticAC", ""), "[", ""), "]", "")
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                MainProgram.MobData_AC_bash = Mid(mscstr, 1, tmp2 - 1)
                                If MainProgram.MobData_AC_bash = "" Then MainProgram.MobData_AC_bash = "0"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 1 Then
                                MainProgram.MobData_AC_slash = Mid(mscstr, tmp3, tmp2 - tmp3)
                                If MainProgram.MobData_AC_slash = "" Then MainProgram.MobData_AC_slash = "0"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 2 Then
                                MainProgram.MobData_AC_pierce = Mid(mscstr, tmp3, tmp2 - tmp3)
                                If MainProgram.MobData_AC_pierce = "" Then MainProgram.MobData_AC_pierce = "0"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 3 Then
                                MainProgram.MobData_AC_fist = Mid(mscstr, tmp3, tmp2 - tmp3)
                                If MainProgram.MobData_AC_fist = "" Then MainProgram.MobData_AC_fist = "0"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 4 Then
                                MainProgram.MobData_AC_exotic = Mid(mscstr, tmp3, tmp2 - tmp3)
                                If MainProgram.MobData_AC_exotic = "" Then MainProgram.MobData_AC_exotic = "0"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        MainProgram.MobData_STR_bash = "0"
        MainProgram.MobData_STR_slash = "0"
        MainProgram.MobData_STR_pierce = "0"
        MainProgram.MobData_STR_fist = "0"
        MainProgram.MobData_STR_exotic = "0"
        tmp0 = InStr(MainProgram.MobData, "ARMST#" + npcnum + "(")
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "ARMST#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Mid(MainProgram.MobData, InStr(MainProgram.MobData, "ARMST#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "ARMST#" + npcnum + "(") - 7 - Len(npcnum)), "BashStr", ""), "SlashStr", ""), "PierceStr", ""), "FistStr", ""), "ExoticStr", ""), "[", ""), "]", "")
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                MainProgram.MobData_STR_bash = Mid(mscstr, 1, tmp2 - 1)
                                If MainProgram.MobData_STR_bash = "" Then MainProgram.MobData_STR_bash = "0"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 1 Then
                                MainProgram.MobData_STR_slash = Mid(mscstr, tmp3, tmp2 - tmp3)
                                If MainProgram.MobData_STR_slash = "" Then MainProgram.MobData_STR_slash = "0"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 2 Then
                                MainProgram.MobData_STR_pierce = Mid(mscstr, tmp3, tmp2 - tmp3)
                                If MainProgram.MobData_STR_pierce = "" Then MainProgram.MobData_STR_pierce = "0"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 3 Then
                                MainProgram.MobData_STR_fist = Mid(mscstr, tmp3, tmp2 - tmp3)
                                If MainProgram.MobData_STR_fist = "" Then MainProgram.MobData_STR_fist = "0"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 4 Then
                                MainProgram.MobData_STR_exotic = Mid(mscstr, tmp3, tmp2 - tmp3)
                                If MainProgram.MobData_STR_exotic = "" Then MainProgram.MobData_STR_exotic = "0"
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "ELERE#" + npcnum + "(")
        MainProgram.MobData_RES_fire = "0"
        MainProgram.MobData_RES_water = "0"
        MainProgram.MobData_RES_air = "0"
        MainProgram.MobData_RES_earth = "0"
        MainProgram.MobData_RES_spirit = "0"
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "ELERE#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Mid(MainProgram.MobData, InStr(MainProgram.MobData, "ELERE#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "ELERE#" + npcnum + "(") - 7 - Len(npcnum)), "FireRes", ""), "WaterRes", ""), "AirRes", ""), "EarthRes", ""), "SpiritRes", ""), "[", ""), "]", "")
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                MainProgram.MobData_RES_fire = Mid(mscstr, 1, tmp2 - 1)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 1 Then
                                MainProgram.MobData_RES_water = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 2 Then
                                MainProgram.MobData_RES_air = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 3 Then
                                MainProgram.MobData_RES_earth = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 4 Then
                                MainProgram.MobData_RES_spirit = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "ELEAM#" + npcnum + "(")
        MainProgram.MobData_AMP_fire = "0"
        MainProgram.MobData_AMP_water = "0"
        MainProgram.MobData_AMP_air = "0"
        MainProgram.MobData_AMP_earth = "0"
        MainProgram.MobData_AMP_spirit = "0"
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "ELEAM#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Mid(MainProgram.MobData, InStr(MainProgram.MobData, "ELEAM#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "ELEAM#" + npcnum + "(") - 7 - Len(npcnum)), "FireAmp", ""), "WaterAmp", ""), "AirAmp", ""), "EarthAmp", ""), "SpiritAmp", ""), "[", ""), "]", "")
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                MainProgram.MobData_AMP_fire = Mid(mscstr, 1, tmp2 - 1)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 1 Then
                                MainProgram.MobData_AMP_water = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 2 Then
                                MainProgram.MobData_AMP_air = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 3 Then
                                MainProgram.MobData_AMP_earth = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 4 Then
                                MainProgram.MobData_AMP_spirit = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "SELRE#" + npcnum + "(")
        MainProgram.MobData_RES_subfire = "0"
        MainProgram.MobData_RES_subwater = "0"
        MainProgram.MobData_RES_subair = "0"
        MainProgram.MobData_RES_subearth = "0"
        MainProgram.MobData_RES_subspirit = "0"
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "SELRE#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Mid(MainProgram.MobData, InStr(MainProgram.MobData, "SELRE#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "SELRE#" + npcnum + "(") - 7 - Len(npcnum)), "SubFireRes", ""), "SubWaterRes", ""), "SubAirRes", ""), "SubEarthRes", ""), "SubSpiritRes", ""), "[", ""), "]", "")
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                MainProgram.MobData_RES_subfire = Mid(mscstr, 1, tmp2 - 1)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 1 Then
                                MainProgram.MobData_RES_subwater = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 2 Then
                                MainProgram.MobData_RES_subair = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 3 Then
                                MainProgram.MobData_RES_subearth = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 4 Then
                                MainProgram.MobData_RES_subspirit = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "SELAM#" + npcnum + "(")
        MainProgram.MobData_AMP_subfire = "0"
        MainProgram.MobData_AMP_subwater = "0"
        MainProgram.MobData_AMP_subair = "0"
        MainProgram.MobData_AMP_subearth = "0"
        MainProgram.MobData_AMP_subspirit = "0"
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "SELAM#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Mid(MainProgram.MobData, InStr(MainProgram.MobData, "SELAM#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "SELAM#" + npcnum + "(") - 7 - Len(npcnum)), "SubFireAmp", ""), "SubWaterAmp", ""), "SubAirAmp", ""), "SubEarthAmp", ""), "SubSpiritAmp", ""), "[", ""), "]", "")
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                MainProgram.MobData_AMP_subfire = Mid(mscstr, 1, tmp2 - 1)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 1 Then
                                MainProgram.MobData_AMP_subwater = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 2 Then
                                MainProgram.MobData_AMP_subair = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 3 Then
                                MainProgram.MobData_AMP_subearth = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 4 Then
                                MainProgram.MobData_AMP_subspirit = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "MOUNT#" + npcnum + "(")
        If tmp0 > 0 Then : stepnum = 0
            For tmp1 = InStr(MainProgram.MobData, "MOUNT#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    mscstr = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "MOUNT#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "MOUNT#" + npcnum + "(") - 7 - Len(npcnum))
                    For tmp2 = 1 To Len(mscstr) + 1 Step 1
                        If Mid(mscstr + ",", tmp2, 1) = "," Then
                            If stepnum = 0 Then
                                MainProgram.MobData_MOUNT_bag = Mid(mscstr, 1, tmp2 - 1)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 1 Then
                                MainProgram.MobData_MOUNT_speed = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 2 Then
                                MainProgram.MobData_MOUNT_lvlreq = Mid(mscstr, tmp3, tmp2 - tmp3)
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            ElseIf stepnum = 3 Then
                                Dim tmp4 As Short
                                Dim tmp5 As Short
                                Dim tmpstr2 As String = Mid(mscstr, tmp3, tmp2 - 3)
                                For tmp4 = 1 To Len(tmpstr2) Step 1
                                    If Mid(tmpstr2, tmp4, 1) = "S" Then
                                        MainProgram.MobData_MOUNT_soverncost = Mid(tmpstr2, 1, tmp4 - 1)
                                        tmp5 = tmp4 + 2
                                    ElseIf Mid(tmpstr2, tmp4, 1) = "D" Then
                                        MainProgram.MobData_MOUNT_dovercost = Mid(tmpstr2, tmp5, tmp4 - tmp5)
                                        tmp5 = tmp4 + 2
                                    ElseIf Mid(tmpstr2, tmp4, 1) = "V" Then
                                        MainProgram.MobData_MOUNT_verncost = Mid(tmpstr2, tmp5, tmp4 - tmp5)
                                        Exit For
                                    End If
                                Next
                                tmp3 = tmp2 + 1
                                stepnum += 1
                            End If
                        End If
                    Next
                    Exit For
                End If
            Next
        End If
        MainProgram.MobData_HITPO = "0"
        MainProgram.MobData_WILLP = "0"
        MainProgram.MobData_STAMP = "0"
        MainProgram.MobData_LEVEL = "0"
        tmp0 = InStr(MainProgram.MobData, "HITPO#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(MainProgram.MobData, "HITPO#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    MainProgram.MobData_HITPO = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "HITPO#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "HITPO#" + npcnum + "(") - 7 - Len(npcnum))
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "WILLP#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(MainProgram.MobData, "WILLP#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    MainProgram.MobData_WILLP = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "WILLP#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "WILLP#" + npcnum + "(") - 7 - Len(npcnum))
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "STAMP#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(MainProgram.MobData, "STAMP#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    MainProgram.MobData_STAMP = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "STAMP#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "STAMP#" + npcnum + "(") - 7 - Len(npcnum))
                    Exit For
                End If
            Next
        End If
        tmp0 = InStr(MainProgram.MobData, "LEVEL#" + npcnum + "(")
        If tmp0 > 0 Then
            For tmp1 = InStr(MainProgram.MobData, "LEVEL#" + npcnum + "(") To Len(MainProgram.MobData) Step 1
                If Mid(MainProgram.MobData, tmp1, 1) = ")" Then
                    MainProgram.MobData_LEVEL = Mid(MainProgram.MobData, InStr(MainProgram.MobData, "LEVEL#" + npcnum + "(") + 7 + Len(npcnum), tmp1 - InStr(MainProgram.MobData, "LEVEL#" + npcnum + "(") - 7 - Len(npcnum))
                    Exit For
                End If
            Next
        End If
    End Sub
End Module
